﻿namespace WMS6.SQLServerDAL
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.DBUtility;
    using WMS6.IDAL;
    using WMS6.QueryEntity;

    public class SalesOrderDetailDA : ISalesOrderDetailDA
    {
        private string ACTUAL_SHIP_DATE = "@ACTUAL_SHIP_DATE";
        private string ADJUSTED_QTY = "@ADJUSTED_QTY";
        private string ALT_SKU_ID = "@ALT_SKU_ID";
        private string CREATED_BY = "@CREATED_BY";
        private string EXTENDED_PRICE = "@EXTENDED_PRICE";
        private string EXTERN_LINE_ID = "@EXTERN_LINE_ID";
        private string EXTERN_ORDER_ID = "@EXTERN_ORDER_ID";
        private string IS_SUBSTITUTE = "@IS_SUBSTITUTE";
        private string LINE_ID = "@LINE_ID";
        private string OK_TO_SUBSTITUTE = "@OK_TO_SUBSTITUTE";
        private string OPEN_QTY = "@OPEN_QTY";
        private string ORDER_ID = "@ORDER_ID";
        private string ORIGINAL_QTY = "@ORIGINAL_QTY";
        private string OWNER_ID = "@OWNER_ID";
        private string PACK_ID = "@PACK_ID";
        private string PRODUCT_CUBE = "@PRODUCT_CUBE";
        private string PRODUCT_WEIGHT = "@PRODUCT_WEIGHT";
        private string REMARK = "@REMARK";
        private string SHIPPED_QTY = "@SHIPPED_QTY";
        private string SKU_ID = "@SKU_ID";
        private string SQL_CHECK_SALES_ORDER_DETAIL_ID_UNIQUE = " SELECT COUNT(1) FROM @_@SALES_ORDER_DETAIL WHERE ORDER_ID = @ORDER_ID AND LINE_ID = @LINE_ID ";
        private string SQL_DELETE_SALES_ORDER_DETAIL = " DELETE FROM @_@SALES_ORDER_DETAIL WHERE ORDER_ID = @ORDER_ID AND LINE_ID = @LINE_ID ";
        private string SQL_DELETE_SALES_ORDER_DETAIL_BY_ORDER_ID = " DELETE FROM @_@SALES_ORDER_DETAIL WHERE ORDER_ID = @ORDER_ID ";
        private string SQL_INSERT_SALES_ORDER_DETAIL = " INSERT INTO @_@SALES_ORDER_DETAIL ( WH_ID, ORDER_ID, LINE_ID, EXTERN_ORDER_ID, EXTERN_LINE_ID, SKU_ID, ALT_SKU_ID, OWNER_ID, ORIGINAL_QTY, OPEN_QTY, SHIPPED_QTY, ADJUSTED_QTY, UOM_ID, PACK_ID, STATUS, UNIT_PRICE, TAX01, TAX02, EXTENDED_PRICE, PRODUCT_WEIGHT, PRODUCT_CUBE, ACTUAL_SHIP_DATE, IS_SUBSTITUTE, OK_TO_SUBSTITUTE, UDF1, UDF2, UDF3, UDF4, UDF5, UDF6, UDF7, UDF8, UDF9, UDF10, REMARK, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE) VALUES ( @WH_ID, @ORDER_ID, @LINE_ID, @EXTERN_ORDER_ID, @EXTERN_LINE_ID, @SKU_ID, @ALT_SKU_ID, @OWNER_ID, @ORIGINAL_QTY, @OPEN_QTY, @SHIPPED_QTY, @ADJUSTED_QTY, @UOM_ID, @PACK_ID, @STATUS, @UNIT_PRICE, @TAX01, @TAX02, @EXTENDED_PRICE, @PRODUCT_WEIGHT, @PRODUCT_CUBE, @ACTUAL_SHIP_DATE, @IS_SUBSTITUTE, @OK_TO_SUBSTITUTE, @UDF1, @UDF2, @UDF3, @UDF4, @UDF5, @UDF6, @UDF7, @UDF8, @UDF9, @UDF10, @REMARK, @CREATED_BY, GETDATE(), @UPDATED_BY, GETDATE() )  ";
        private string SQL_SELECT_ALL_SALES_ORDER_DETAIL = "SELECT  SOD.ROWID, SOD.WH_ID, SOD.ORDER_ID, SOD.LINE_ID, SOD.EXTERN_ORDER_ID, SOD.EXTERN_LINE_ID, SOD.SKU_ID, SOD.ALT_SKU_ID, SOD.OWNER_ID, SOD.ORIGINAL_QTY, SOD.OPEN_QTY, SOD.SHIPPED_QTY, SOD.ADJUSTED_QTY, SOD.UOM_ID, SOD.PACK_ID, SOD.STATUS, SOD.UNIT_PRICE, SOD.TAX01, SOD.TAX02, SOD.EXTENDED_PRICE, SOD.PRODUCT_WEIGHT, SOD.PRODUCT_CUBE, SOD.ACTUAL_SHIP_DATE, SOD.IS_SUBSTITUTE, SOD.OK_TO_SUBSTITUTE, SOD.UDF1, SOD.UDF2, SOD.UDF3, SOD.UDF4, SOD.UDF5, SOD.UDF6, SOD.UDF7, SOD.UDF8, SOD.UDF9, SOD.UDF10, SOD.REMARK, SOD.TS, SOD.CREATED_BY, SOD.CREATED_DATE, SOD.UPDATED_BY, SOD.UPDATED_DATE,T.[TEXT] AS STATUSD, SKU.DESCR AS SKU_DESCR,UOM.UOM_DESCR AS UOM_DESCR FROM  @_@SALES_ORDER_DETAIL SOD  LEFT JOIN @_@SKU SKU ON SOD.OWNER_ID = SKU.OWNER_ID AND SOD.SKU_ID = SKU.SKU_ID  LEFT JOIN @_@SYS_CODE_DETAIL SCD ON SCD.SYS_CODE = SOD.STATUS AND SCD.SYS_CODE_TYPE = 'ORDERSTATUS' LEFT JOIN @_@UOM UOM ON SOD.UOM_ID = UOM.UOM_ID LEFT JOIN SYSADM.TRANSLATION T ON 'ORDERSTATUS.'+SOD.STATUS = T.ITEM_ID AND  T.ITEM_TYPE = 'SYS_CODE_DETAIL' AND T.LANG+'-'+T.COUNTRY = '@LANGUAGE' ";
        private string SQL_UPDATE_SALES_ORDER_DETAIL = " UPDATE @_@SALES_ORDER_DETAIL SET WH_ID = @WH_ID, EXTERN_ORDER_ID = @EXTERN_ORDER_ID, EXTERN_LINE_ID = @EXTERN_LINE_ID, SKU_ID = @SKU_ID, ALT_SKU_ID = @ALT_SKU_ID, OWNER_ID = @OWNER_ID, ORIGINAL_QTY = @ORIGINAL_QTY, OPEN_QTY = @OPEN_QTY, SHIPPED_QTY = @SHIPPED_QTY, ADJUSTED_QTY = @ADJUSTED_QTY, UOM_ID = @UOM_ID, PACK_ID = @PACK_ID, STATUS = @STATUS, UNIT_PRICE = @UNIT_PRICE, TAX01 = @TAX01, TAX02 = @TAX02, EXTENDED_PRICE = @EXTENDED_PRICE, PRODUCT_WEIGHT = @PRODUCT_WEIGHT, PRODUCT_CUBE = @PRODUCT_CUBE, ACTUAL_SHIP_DATE = @ACTUAL_SHIP_DATE, IS_SUBSTITUTE = @IS_SUBSTITUTE, OK_TO_SUBSTITUTE = @OK_TO_SUBSTITUTE, UDF1 = @UDF1, UDF2 = @UDF2, UDF3 = @UDF3, UDF4 = @UDF4, UDF5 = @UDF5, UDF6 = @UDF6, UDF7 = @UDF7, UDF8 = @UDF8, UDF9 = @UDF9, UDF10 = @UDF10, REMARK = @REMARK, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE ORDER_ID = @ORDER_ID AND LINE_ID = @LINE_ID  ";
        private string SQL_UPDATE_SALES_ORDER_DETAIL_STATUS = " UPDATE @_@SALES_ORDER_DETAIL SET STATUS = @STATUS, SHIPPED_QTY = SHIPPED_QTY + @SHIPPED_QTY, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE ORDER_ID = @ORDER_ID AND LINE_ID = @LINE_ID ";
        private string SQL_UPDATE_SALES_ORDER_DETAIL_STATUS_QTY = " UPDATE @_@SALES_ORDER_DETAIL SET STATUS = @STATUS, SHIPPED_QTY = SHIPPED_QTY + @SHIPPED_QTY,IS_SUBSTITUTE = IS_SUBSTITUTE + @IS_SUBSTITUTE, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE ORDER_ID = @ORDER_ID AND LINE_ID = @LINE_ID ";
        private string SQL_UPDATE_SALES_ORDER_DETAIL_STATUS2 = " UPDATE @_@SALES_ORDER_DETAIL SET STATUS = @STATUS, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE ORDER_ID = @ORDER_ID ";
        private string STATUS = "@STATUS";
        private string TAX01 = "@TAX01";
        private string TAX02 = "@TAX02";
        private string TS = "@TS";
        private string UDF1 = "@UDF1";
        private string UDF10 = "@UDF10";
        private string UDF2 = "@UDF2";
        private string UDF3 = "@UDF3";
        private string UDF4 = "@UDF4";
        private string UDF5 = "@UDF5";
        private string UDF6 = "@UDF6";
        private string UDF7 = "@UDF7";
        private string UDF8 = "@UDF8";
        private string UDF9 = "@UDF9";
        private string UNIT_PRICE = "@UNIT_PRICE";
        private string UOM_ID = "@UOM_ID";
        private string UPDATED_BY = "@UPDATED_BY";
        private string WH_ID = "@WH_ID";

        public bool CheckSalesOrderDetailIDUnique(string salesOrderDetailID, string lineID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderDetailID), new SqlParameter("@LINE_ID", lineID) };
            return (DBHelper.ExecuteScalar(CommandType.Text, this.SQL_CHECK_SALES_ORDER_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public bool CheckSalesOrderDetailIDUnique(DataBase dataBase, DbTransaction tran, string salesOrderDetailID, string lineID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderDetailID), new SqlParameter("@LINE_ID", lineID) };
            return (dataBase.ExecuteScalar(tran, CommandType.Text, this.SQL_CHECK_SALES_ORDER_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public int DeleteSalesOrderDetail(List<string> salesOrderDetailID, string whLoginID)
        {
            int result = 0;
            DataBase dataBase = new DataBase();
            DbConnection conn = dataBase.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int j = 0; j < salesOrderDetailID.Count; j++)
                {
                    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderDetailID[j]) };
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_SALES_ORDER_DETAIL_BY_ORDER_ID.Replace("@_@", whLoginID), paras);
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int DeleteSalesOrderDetail(string salesOrderDetailID, List<string> lineID, string whLoginID)
        {
            int result = 0;
            DataBase dataBase = new DataBase();
            DbConnection conn = dataBase.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int j = 0; j < lineID.Count; j++)
                {
                    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderDetailID), new SqlParameter("@LINE_ID", lineID[j]) };
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_SALES_ORDER_DETAIL.Replace("@_@", whLoginID), paras);
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int DeleteSalesOrderDetail(DataBase dataBase, DbTransaction tran, List<string> salesOrderDetailID, string whLoginID)
        {
            int result = 0;
            try
            {
                for (int j = 0; j < salesOrderDetailID.Count; j++)
                {
                    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderDetailID[j]) };
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_SALES_ORDER_DETAIL_BY_ORDER_ID.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int DeleteSalesOrderDetail(DataBase dataBase, DbTransaction tran, string salesOrderDetailID, List<string> lineID, string whLoginID)
        {
            int result = 0;
            try
            {
                for (int j = 0; j < lineID.Count; j++)
                {
                    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderDetailID), new SqlParameter("@LINE_ID", lineID[j]) };
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_SALES_ORDER_DETAIL.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public DataSet GetAllSalesOrderDetail(string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_SALES_ORDER_DETAIL.Replace("@_@", whLoginID);
            return DBHelper.ExecuteDataSet(CommandType.Text, sql);
        }

        public DataSet GetAllSalesOrderDetail(DataBase dataBase, DbTransaction tran, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_SALES_ORDER_DETAIL.Replace("@_@", whLoginID);
            return dataBase.ExecuteDataSet(tran, CommandType.Text, sql);
        }

        public List<SalesOrderDetailInfo> GetSalesOrderDetailByID(string salesorderdetailID, string whLoginID, PubParasInfo pubParasInfo)
        {
            string sql = this.SQL_SELECT_ALL_SALES_ORDER_DETAIL.Replace("@_@", whLoginID).Replace("@LANGUAGE", pubParasInfo.UserLanguage) + " WHERE ORDER_ID = @ORDER_ID  ORDER BY SOD.LINE_ID ASC ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesorderdetailID) };
            List<SalesOrderDetailInfo> salesOrderDetailInfos = new List<SalesOrderDetailInfo>();
            SalesOrderDetailInfo salesOrderDetailInfo = null;
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                while (reader.Read())
                {
                    DateTime CS00002;
                    salesOrderDetailInfo = new SalesOrderDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ORDER_ID"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["EXTERN_ORDER_ID"].ToString(), reader["EXTERN_LINE_ID"].ToString(), reader["SKU_ID"].ToString(), reader["ALT_SKU_ID"].ToString(), reader["OWNER_ID"].ToString(), (reader["ORIGINAL_QTY"].ToString() != "") ? decimal.Parse(reader["ORIGINAL_QTY"].ToString()) : 0M, (reader["OPEN_QTY"].ToString() != "") ? decimal.Parse(reader["OPEN_QTY"].ToString()) : 0M, (reader["SHIPPED_QTY"].ToString() != "") ? decimal.Parse(reader["SHIPPED_QTY"].ToString()) : 0M, (reader["ADJUSTED_QTY"].ToString() != "") ? decimal.Parse(reader["ADJUSTED_QTY"].ToString()) : 0M, reader["UOM_ID"].ToString(), reader["PACK_ID"].ToString(), reader["STATUS"].ToString(), (reader["UNIT_PRICE"].ToString() != "") ? ((double) float.Parse(reader["UNIT_PRICE"].ToString())) : ((double) 0f), (reader["TAX01"].ToString() != "") ? ((double) float.Parse(reader["TAX01"].ToString())) : ((double) 0f), (reader["TAX02"].ToString() != "") ? ((double) float.Parse(reader["TAX02"].ToString())) : ((double) 0f), (reader["EXTENDED_PRICE"].ToString() != "") ? ((double) float.Parse(reader["EXTENDED_PRICE"].ToString())) : ((double) 0f), (reader["PRODUCT_WEIGHT"].ToString() != "") ? ((double) float.Parse(reader["PRODUCT_WEIGHT"].ToString())) : ((double) 0f), (reader["PRODUCT_CUBE"].ToString() != "") ? ((double) float.Parse(reader["PRODUCT_CUBE"].ToString())) : ((double) 0f), (reader["ACTUAL_SHIP_DATE"].ToString() != "") ? DateTime.Parse(reader["ACTUAL_SHIP_DATE"].ToString()) : (CS00002 = new DateTime()), (reader["IS_SUBSTITUTE"].ToString() != "") ? int.Parse(reader["IS_SUBSTITUTE"].ToString()) : 0, (reader["OK_TO_SUBSTITUTE"].ToString() != "") ? int.Parse(reader["OK_TO_SUBSTITUTE"].ToString()) : 0, reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["REMARK"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["STATUSD"].ToString(), reader["SKU_DESCR"].ToString(), reader["UOM_DESCR"].ToString());
                    salesOrderDetailInfos.Add(salesOrderDetailInfo);
                }
            }
            return salesOrderDetailInfos;
        }

        public SalesOrderDetailInfo GetSalesOrderDetailByID(string salesorderdetailID, string lineID, string whLoginID, PubParasInfo pubParasInfo)
        {
            string sql = this.SQL_SELECT_ALL_SALES_ORDER_DETAIL.Replace("@_@", whLoginID).Replace("@LANGUAGE", pubParasInfo.UserLanguage) + " WHERE ORDER_ID = @ORDER_ID AND LINE_ID = @LINE_ID ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesorderdetailID), new SqlParameter("@LINE_ID", lineID) };
            SalesOrderDetailInfo salesOrderDetailInfo = null;
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                if (reader.Read())
                {
                    DateTime CS00003;
                    salesOrderDetailInfo = new SalesOrderDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ORDER_ID"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["EXTERN_ORDER_ID"].ToString(), reader["EXTERN_LINE_ID"].ToString(), reader["SKU_ID"].ToString(), reader["ALT_SKU_ID"].ToString(), reader["OWNER_ID"].ToString(), (reader["ORIGINAL_QTY"].ToString() != "") ? decimal.Parse(reader["ORIGINAL_QTY"].ToString()) : 0M, (reader["OPEN_QTY"].ToString() != "") ? decimal.Parse(reader["OPEN_QTY"].ToString()) : 0M, (reader["SHIPPED_QTY"].ToString() != "") ? decimal.Parse(reader["SHIPPED_QTY"].ToString()) : 0M, (reader["ADJUSTED_QTY"].ToString() != "") ? decimal.Parse(reader["ADJUSTED_QTY"].ToString()) : 0M, reader["UOM_ID"].ToString(), reader["PACK_ID"].ToString(), reader["STATUS"].ToString(), (reader["UNIT_PRICE"].ToString() != "") ? ((double) float.Parse(reader["UNIT_PRICE"].ToString())) : ((double) 0f), (reader["TAX01"].ToString() != "") ? ((double) float.Parse(reader["TAX01"].ToString())) : ((double) 0f), (reader["TAX02"].ToString() != "") ? ((double) float.Parse(reader["TAX02"].ToString())) : ((double) 0f), (reader["EXTENDED_PRICE"].ToString() != "") ? ((double) float.Parse(reader["EXTENDED_PRICE"].ToString())) : ((double) 0f), (reader["PRODUCT_WEIGHT"].ToString() != "") ? ((double) float.Parse(reader["PRODUCT_WEIGHT"].ToString())) : ((double) 0f), (reader["PRODUCT_CUBE"].ToString() != "") ? ((double) float.Parse(reader["PRODUCT_CUBE"].ToString())) : ((double) 0f), (reader["ACTUAL_SHIP_DATE"].ToString() != "") ? DateTime.Parse(reader["ACTUAL_SHIP_DATE"].ToString()) : (CS00003 = new DateTime()), (reader["IS_SUBSTITUTE"].ToString() != "") ? int.Parse(reader["IS_SUBSTITUTE"].ToString()) : 0, (reader["OK_TO_SUBSTITUTE"].ToString() != "") ? int.Parse(reader["OK_TO_SUBSTITUTE"].ToString()) : 0, reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["REMARK"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00003 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime(), reader["STATUSD"].ToString(), reader["SKU_DESCR"].ToString(), reader["UOM_DESCR"].ToString());
                }
            }
            return salesOrderDetailInfo;
        }

        public List<SalesOrderDetailInfo> GetSalesOrderDetailByID(DataBase dataBase, DbTransaction tran, string salesorderdetailID, string whLoginID, PubParasInfo pubParasInfo)
        {
            string sql = this.SQL_SELECT_ALL_SALES_ORDER_DETAIL.Replace("@_@", whLoginID).Replace("@LANGUAGE", pubParasInfo.UserLanguage) + " WHERE ORDER_ID = @ORDER_ID ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesorderdetailID) };
            List<SalesOrderDetailInfo> salesOrderDetailInfos = new List<SalesOrderDetailInfo>();
            SalesOrderDetailInfo salesOrderDetailInfo = null;
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            while (reader.Read())
            {
                DateTime CS00002;
                salesOrderDetailInfo = new SalesOrderDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ORDER_ID"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["EXTERN_ORDER_ID"].ToString(), reader["EXTERN_LINE_ID"].ToString(), reader["SKU_ID"].ToString(), reader["ALT_SKU_ID"].ToString(), reader["OWNER_ID"].ToString(), (reader["ORIGINAL_QTY"].ToString() != "") ? decimal.Parse(reader["ORIGINAL_QTY"].ToString()) : 0M, (reader["OPEN_QTY"].ToString() != "") ? decimal.Parse(reader["OPEN_QTY"].ToString()) : 0M, (reader["SHIPPED_QTY"].ToString() != "") ? decimal.Parse(reader["SHIPPED_QTY"].ToString()) : 0M, (reader["ADJUSTED_QTY"].ToString() != "") ? decimal.Parse(reader["ADJUSTED_QTY"].ToString()) : 0M, reader["UOM_ID"].ToString(), reader["PACK_ID"].ToString(), reader["STATUS"].ToString(), (reader["UNIT_PRICE"].ToString() != "") ? ((double) float.Parse(reader["UNIT_PRICE"].ToString())) : ((double) 0f), (reader["TAX01"].ToString() != "") ? ((double) float.Parse(reader["TAX01"].ToString())) : ((double) 0f), (reader["TAX02"].ToString() != "") ? ((double) float.Parse(reader["TAX02"].ToString())) : ((double) 0f), (reader["EXTENDED_PRICE"].ToString() != "") ? ((double) float.Parse(reader["EXTENDED_PRICE"].ToString())) : ((double) 0f), (reader["PRODUCT_WEIGHT"].ToString() != "") ? ((double) float.Parse(reader["PRODUCT_WEIGHT"].ToString())) : ((double) 0f), (reader["PRODUCT_CUBE"].ToString() != "") ? ((double) float.Parse(reader["PRODUCT_CUBE"].ToString())) : ((double) 0f), (reader["ACTUAL_SHIP_DATE"].ToString() != "") ? DateTime.Parse(reader["ACTUAL_SHIP_DATE"].ToString()) : (CS00002 = new DateTime()), (reader["IS_SUBSTITUTE"].ToString() != "") ? int.Parse(reader["IS_SUBSTITUTE"].ToString()) : 0, (reader["OK_TO_SUBSTITUTE"].ToString() != "") ? int.Parse(reader["OK_TO_SUBSTITUTE"].ToString()) : 0, reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["REMARK"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["STATUSD"].ToString(), reader["SKU_DESCR"].ToString(), reader["UOM_DESCR"].ToString());
                salesOrderDetailInfos.Add(salesOrderDetailInfo);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return salesOrderDetailInfos;
        }

        public SalesOrderDetailInfo GetSalesOrderDetailByID(DataBase dataBase, DbTransaction tran, string salesorderdetailID, string lineID, string whLoginID, PubParasInfo pubParasInfo)
        {
            string sql = this.SQL_SELECT_ALL_SALES_ORDER_DETAIL.Replace("@_@", whLoginID).Replace("@LANGUAGE", pubParasInfo.UserLanguage) + " WHERE ORDER_ID = @ORDER_ID AND LINE_ID = @LINE_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesorderdetailID), new SqlParameter("@LINE_ID", lineID) };
            SalesOrderDetailInfo salesOrderDetailInfo = null;
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            if (reader.Read())
            {
                DateTime CS00003;
                salesOrderDetailInfo = new SalesOrderDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ORDER_ID"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["EXTERN_ORDER_ID"].ToString(), reader["EXTERN_LINE_ID"].ToString(), reader["SKU_ID"].ToString(), reader["ALT_SKU_ID"].ToString(), reader["OWNER_ID"].ToString(), (reader["ORIGINAL_QTY"].ToString() != "") ? decimal.Parse(reader["ORIGINAL_QTY"].ToString()) : 0M, (reader["OPEN_QTY"].ToString() != "") ? decimal.Parse(reader["OPEN_QTY"].ToString()) : 0M, (reader["SHIPPED_QTY"].ToString() != "") ? decimal.Parse(reader["SHIPPED_QTY"].ToString()) : 0M, (reader["ADJUSTED_QTY"].ToString() != "") ? decimal.Parse(reader["ADJUSTED_QTY"].ToString()) : 0M, reader["UOM_ID"].ToString(), reader["PACK_ID"].ToString(), reader["STATUS"].ToString(), (reader["UNIT_PRICE"].ToString() != "") ? ((double) float.Parse(reader["UNIT_PRICE"].ToString())) : ((double) 0f), (reader["TAX01"].ToString() != "") ? ((double) float.Parse(reader["TAX01"].ToString())) : ((double) 0f), (reader["TAX02"].ToString() != "") ? ((double) float.Parse(reader["TAX02"].ToString())) : ((double) 0f), (reader["EXTENDED_PRICE"].ToString() != "") ? ((double) float.Parse(reader["EXTENDED_PRICE"].ToString())) : ((double) 0f), (reader["PRODUCT_WEIGHT"].ToString() != "") ? ((double) float.Parse(reader["PRODUCT_WEIGHT"].ToString())) : ((double) 0f), (reader["PRODUCT_CUBE"].ToString() != "") ? ((double) float.Parse(reader["PRODUCT_CUBE"].ToString())) : ((double) 0f), (reader["ACTUAL_SHIP_DATE"].ToString() != "") ? DateTime.Parse(reader["ACTUAL_SHIP_DATE"].ToString()) : (CS00003 = new DateTime()), (reader["IS_SUBSTITUTE"].ToString() != "") ? int.Parse(reader["IS_SUBSTITUTE"].ToString()) : 0, (reader["OK_TO_SUBSTITUTE"].ToString() != "") ? int.Parse(reader["OK_TO_SUBSTITUTE"].ToString()) : 0, reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["REMARK"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00003 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime(), reader["STATUSD"].ToString(), reader["SKU_DESCR"].ToString(), reader["UOM_DESCR"].ToString());
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return salesOrderDetailInfo;
        }

        public DataSet GetSalesOrderDetailByQueryList(List<string> sqlWhere, SalesOrderDetailQueryEntity salesorderdetailQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_SALES_ORDER_DETAIL.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            if (!salesorderdetailQuery.IsGetAll)
            {
                temp = PagingHelper.GetPagingSQL(temp, salesorderdetailQuery.CurrentPage, salesorderdetailQuery.PageSize, salesorderdetailQuery.SortField, salesorderdetailQuery.SortDirection);
            }
            return DBHelper.ExecuteDataSet(CommandType.Text, temp);
        }

        public DataSet GetSalesOrderDetailByQueryList(DataBase dataBase, DbTransaction tran, List<string> sqlWhere, SalesOrderDetailQueryEntity salesorderdetailQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_SALES_ORDER_DETAIL.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            if (!salesorderdetailQuery.IsGetAll)
            {
                temp = PagingHelper.GetPagingSQL(temp, salesorderdetailQuery.CurrentPage, salesorderdetailQuery.PageSize, salesorderdetailQuery.SortField, salesorderdetailQuery.SortDirection);
            }
            return dataBase.ExecuteDataSet(tran, CommandType.Text, temp);
        }

        public int InsertSalesOrderDetail(SalesOrderDetailInfo salesOrderDetailInfo, string whLoginID)
        {
            int result = 0;
            DataBase db = new DataBase();
            DbConnection conn = db.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                salesOrderDetailInfo.WhID = whLoginID.Substring(0, whLoginID.Length - 1);
                SqlParameter[] paras = this.Set_SalesOrderDetail_Parameters(salesOrderDetailInfo);
                if (paras != null)
                {
                    result += db.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_SALES_ORDER_DETAIL.Replace("@_@", whLoginID), paras);
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int InsertSalesOrderDetail(DataBase dataBase, DbTransaction tran, SalesOrderDetailInfo salesOrderDetailInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                salesOrderDetailInfo.WhID = whLoginID.Substring(0, whLoginID.Length - 1);
                SqlParameter[] paras = this.Set_SalesOrderDetail_Parameters(salesOrderDetailInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_SALES_ORDER_DETAIL.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        private SqlParameter[] Set_SalesOrderDetail_Parameters(SalesOrderDetailInfo salesOrderDetailInfo)
        {
            SqlParameter[] paramArray = new SqlParameter[] { 
                new SqlParameter(this.WH_ID, SqlDbType.VarChar, 30), new SqlParameter(this.ORDER_ID, SqlDbType.VarChar, 20), new SqlParameter(this.LINE_ID, SqlDbType.Int, 4), new SqlParameter(this.EXTERN_ORDER_ID, SqlDbType.VarChar, 50), new SqlParameter(this.EXTERN_LINE_ID, SqlDbType.VarChar, 20), new SqlParameter(this.SKU_ID, SqlDbType.VarChar, 50), new SqlParameter(this.ALT_SKU_ID, SqlDbType.VarChar, 50), new SqlParameter(this.OWNER_ID, SqlDbType.VarChar, 300), new SqlParameter(this.ORIGINAL_QTY, SqlDbType.Decimal, 13), new SqlParameter(this.OPEN_QTY, SqlDbType.Decimal, 13), new SqlParameter(this.SHIPPED_QTY, SqlDbType.Decimal, 13), new SqlParameter(this.ADJUSTED_QTY, SqlDbType.Decimal, 13), new SqlParameter(this.UOM_ID, SqlDbType.VarChar, 20), new SqlParameter(this.PACK_ID, SqlDbType.VarChar, 50), new SqlParameter(this.STATUS, SqlDbType.VarChar, 20), new SqlParameter(this.UNIT_PRICE, SqlDbType.Float, 8), 
                new SqlParameter(this.TAX01, SqlDbType.Float, 8), new SqlParameter(this.TAX02, SqlDbType.Float, 8), new SqlParameter(this.EXTENDED_PRICE, SqlDbType.Float, 8), new SqlParameter(this.PRODUCT_WEIGHT, SqlDbType.Float, 8), new SqlParameter(this.PRODUCT_CUBE, SqlDbType.Float, 8), new SqlParameter(this.ACTUAL_SHIP_DATE, SqlDbType.DateTime, 8), new SqlParameter(this.IS_SUBSTITUTE, SqlDbType.Int, 4), new SqlParameter(this.OK_TO_SUBSTITUTE, SqlDbType.Int, 4), new SqlParameter(this.UDF1, SqlDbType.VarChar, 30), new SqlParameter(this.UDF2, SqlDbType.VarChar, 30), new SqlParameter(this.UDF3, SqlDbType.VarChar, 30), new SqlParameter(this.UDF4, SqlDbType.VarChar, 30), new SqlParameter(this.UDF5, SqlDbType.VarChar, 30), new SqlParameter(this.UDF6, SqlDbType.VarChar, 30), new SqlParameter(this.UDF7, SqlDbType.VarChar, 30), new SqlParameter(this.UDF8, SqlDbType.VarChar, 30), 
                new SqlParameter(this.UDF9, SqlDbType.VarChar, 30), new SqlParameter(this.UDF10, SqlDbType.VarChar, 30), new SqlParameter(this.REMARK, SqlDbType.VarChar, 0x3e8), new SqlParameter(this.CREATED_BY, SqlDbType.VarChar, 20), new SqlParameter(this.UPDATED_BY, SqlDbType.VarChar, 20)
             };
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.WhID))
            {
                paramArray[0].Value = salesOrderDetailInfo.WhID;
            }
            else
            {
                paramArray[0].Value = DBNull.Value;
            }
            paramArray[1].Value = salesOrderDetailInfo.OrderID;
            paramArray[2].Value = salesOrderDetailInfo.LineID;
            paramArray[3].Value = salesOrderDetailInfo.ExternOrderID;
            paramArray[4].Value = salesOrderDetailInfo.ExternLineID;
            paramArray[5].Value = salesOrderDetailInfo.SkuID;
            paramArray[6].Value = salesOrderDetailInfo.AltSkuID;
            paramArray[7].Value = salesOrderDetailInfo.OwnerID;
            paramArray[8].Value = salesOrderDetailInfo.OriginalQty;
            paramArray[9].Value = salesOrderDetailInfo.OpenQty;
            paramArray[10].Value = salesOrderDetailInfo.ShippedQty;
            paramArray[11].Value = salesOrderDetailInfo.AdjustedQty;
            paramArray[12].Value = salesOrderDetailInfo.UomID;
            paramArray[13].Value = salesOrderDetailInfo.PackID;
            paramArray[14].Value = salesOrderDetailInfo.Status;
            paramArray[15].Value = salesOrderDetailInfo.UnitPrice;
            paramArray[0x10].Value = salesOrderDetailInfo.Tax01;
            paramArray[0x11].Value = salesOrderDetailInfo.Tax02;
            paramArray[0x12].Value = salesOrderDetailInfo.ExtendedPrice;
            paramArray[0x13].Value = salesOrderDetailInfo.ProductWeight;
            paramArray[20].Value = salesOrderDetailInfo.ProductCube;
            if (salesOrderDetailInfo.ActualShipDate != new DateTime())
            {
                paramArray[0x15].Value = salesOrderDetailInfo.ActualShipDate;
            }
            else
            {
                paramArray[0x15].Value = DBNull.Value;
            }
            paramArray[0x16].Value = salesOrderDetailInfo.IsSubstitute;
            paramArray[0x17].Value = salesOrderDetailInfo.OkToSubstitute;
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Udf1))
            {
                paramArray[0x18].Value = salesOrderDetailInfo.Udf1;
            }
            else
            {
                paramArray[0x18].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Udf2))
            {
                paramArray[0x19].Value = salesOrderDetailInfo.Udf2;
            }
            else
            {
                paramArray[0x19].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Udf3))
            {
                paramArray[0x1a].Value = salesOrderDetailInfo.Udf3;
            }
            else
            {
                paramArray[0x1a].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Udf4))
            {
                paramArray[0x1b].Value = salesOrderDetailInfo.Udf4;
            }
            else
            {
                paramArray[0x1b].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Udf5))
            {
                paramArray[0x1c].Value = salesOrderDetailInfo.Udf5;
            }
            else
            {
                paramArray[0x1c].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Udf6))
            {
                paramArray[0x1d].Value = salesOrderDetailInfo.Udf6;
            }
            else
            {
                paramArray[0x1d].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Udf7))
            {
                paramArray[30].Value = salesOrderDetailInfo.Udf7;
            }
            else
            {
                paramArray[30].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Udf8))
            {
                paramArray[0x1f].Value = salesOrderDetailInfo.Udf8;
            }
            else
            {
                paramArray[0x1f].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Udf9))
            {
                paramArray[0x20].Value = salesOrderDetailInfo.Udf9;
            }
            else
            {
                paramArray[0x20].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Udf10))
            {
                paramArray[0x21].Value = salesOrderDetailInfo.Udf10;
            }
            else
            {
                paramArray[0x21].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(salesOrderDetailInfo.Remark))
            {
                paramArray[0x22].Value = salesOrderDetailInfo.Remark;
            }
            else
            {
                paramArray[0x22].Value = DBNull.Value;
            }
            paramArray[0x23].Value = salesOrderDetailInfo.CreatedBy;
            paramArray[0x24].Value = salesOrderDetailInfo.UpdatedBy;
            return paramArray;
        }

        public int UpdateSalesOrderDetail(SalesOrderDetailInfo salesOrderDetailInfo, string whLoginID)
        {
            int result = 0;
            DataBase db = new DataBase();
            DbConnection conn = db.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                salesOrderDetailInfo.WhID = whLoginID.Substring(0, whLoginID.Length - 1);
                SqlParameter[] paras = this.Set_SalesOrderDetail_Parameters(salesOrderDetailInfo);
                if (paras != null)
                {
                    result += db.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_SALES_ORDER_DETAIL.Replace("@_@", whLoginID), paras);
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int UpdateSalesOrderDetail(DataBase dataBase, DbTransaction tran, SalesOrderDetailInfo salesOrderDetailInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                salesOrderDetailInfo.WhID = whLoginID.Substring(0, whLoginID.Length - 1);
                SqlParameter[] paras = this.Set_SalesOrderDetail_Parameters(salesOrderDetailInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_SALES_ORDER_DETAIL.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public void UpdateSalesOrderDetailStatus(string salesOrderID, string status, string updatedBy, string whLoginID)
        {
            string sql = this.SQL_UPDATE_SALES_ORDER_DETAIL_STATUS2.Replace("@_@", whLoginID);
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderID), new SqlParameter("@STATUS", status), new SqlParameter("@UPDATED_BY", updatedBy) };
            DBHelper.ExecuteNonQuery(CommandType.Text, sql, paras);
        }

        public void UpdateSalesOrderDetailStatus(DataBase dataBase, DbTransaction tran, string salesOrderID, string status, string updatedBy, string whLoginID)
        {
            string sql = this.SQL_UPDATE_SALES_ORDER_DETAIL_STATUS2.Replace("@_@", whLoginID);
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderID), new SqlParameter("@STATUS", status), new SqlParameter("@UPDATED_BY", updatedBy) };
            dataBase.ExecuteNonQuery(tran, CommandType.Text, sql, paras);
        }

        public void UpdateSalesOrderDetailStatusAndQty(string salesOrderDetailID, string lineID, string status, decimal shippedQty, string updatedBy, string whLoginID)
        {
            string sql = this.SQL_UPDATE_SALES_ORDER_DETAIL_STATUS.Replace("@_@", whLoginID);
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderDetailID), new SqlParameter("@LINE_ID", lineID), new SqlParameter("@STATUS", status), new SqlParameter("@SHIPPED_QTY", shippedQty), new SqlParameter("@UPDATED_BY", updatedBy) };
            DBHelper.ExecuteNonQuery(CommandType.Text, sql, paras);
        }

        public void UpdateSalesOrderDetailStatusAndQty(DataBase dataBase, DbTransaction tran, string salesOrderDetailID, string lineID, string status, decimal shippedQty, string updatedBy, string whLoginID)
        {
            string sql = this.SQL_UPDATE_SALES_ORDER_DETAIL_STATUS.Replace("@_@", whLoginID);
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderDetailID), new SqlParameter("@LINE_ID", lineID), new SqlParameter("@STATUS", status), new SqlParameter("@SHIPPED_QTY", shippedQty), new SqlParameter("@UPDATED_BY", updatedBy) };
            dataBase.ExecuteNonQuery(tran, CommandType.Text, sql, paras);
        }

        public void UpdateSalesOrderDetailStatusAndQty(DataBase dataBase, DbTransaction tran, string salesOrderDetailID, string lineID, string status, decimal shippedQty, decimal isSubSkuQty, string updatedBy, string whLoginID)
        {
            string sql = this.SQL_UPDATE_SALES_ORDER_DETAIL_STATUS.Replace("@_@", whLoginID);
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", salesOrderDetailID), new SqlParameter("@LINE_ID", lineID), new SqlParameter("@STATUS", status), new SqlParameter("@SHIPPED_QTY", shippedQty), new SqlParameter("@IS_SUBSTITUTE", isSubSkuQty), new SqlParameter("@UPDATED_BY", updatedBy) };
            dataBase.ExecuteNonQuery(tran, CommandType.Text, sql, paras);
        }
    }
}

